package com.xlh.openai.handler;

import com.github.xiaoymin.knife4j.core.util.StrUtil;
import com.xlh.openai.service.impl.WebChatServiceImpl;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author <a href="https://github.com/binarywang">Binary Wang</a>
 */
@Component
public class ScanHandler extends AbstractHandler {

    @Override
    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map<String, Object> map,
                                    WxMpService wxMpService, WxSessionManager wxSessionManager) throws WxErrorException {

        String sceneStr = wxMpXmlMessage.getEventKey();
        if(StrUtil.isNotBlank( sceneStr )){
            WebChatServiceImpl.putSceneIdMap( sceneStr, wxMpXmlMessage.getFromUser());
            System.out.println("场景扫描ID");
        }
        return null;
    }
}
